package main

import (
	"context"
	"flag"
	"os"

	"diff.wang/asynqsrv/server/internal/config"
	"diff.wang/asynqsrv/server/internal/logic"
	"diff.wang/asynqsrv/server/internal/svc"
	"github.com/zeromicro/go-zero/core/conf"
	"github.com/zeromicro/go-zero/core/logx"
)

var configFile = flag.String("f", "etc/app.yaml", "Specify the config file")

func main() {
	flag.Parse()

	var c config.Config
	conf.MustLoad(*configFile, &c)

	logx.DisableStat()
	// log、prometheus、trace、metricsUrl.
	if err := c.SetUp(); err != nil {
		panic(err)
	}

	svcCtx := svc.NewServiceContext(c)
	ctx := context.Background()
	cj := logic.NewCronJob(ctx, svcCtx)
	sm := cj.Register()
	if err := svcCtx.AsynqServer.Run(sm); err != nil {
		logx.WithContext(ctx).Errorf("!!!CronJobErr!!! run err:%+v", err)
		os.Exit(1)
	}

}
